<?php declare(strict_types=1);


namespace App\Api\V2\Controller\Lite;

use App\Api\Controllers\BaseController;
use App\Services\PengYiPeng\SPILiteService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class SpiBillController extends BaseController
{

    //spi.alipay.merchant.order.commonisv.bill.query  账单流水查询
    public function billQuery(Request $request): string
    {
        $data = $request->all();
        $url = $request->fullUrl();
        Log::channel("bill-query")->info("billQuery日志" . date("Y-m-d H:i:s", time()), $data);
        //发起支付代码
        $service = new SPILiteService();

        $result = $service->billQuerySPI($data);
        Log::channel("bill-query")->info("billQueryRESULT日志" . date("Y-m-d H:i:s", time()), $result);
        return json_encode($result);
    }


    //spi.alipay.commerce.billdetail.query
    public function billDetailQuery(Request $request): string
    {
        $data = $request->all();
        $url = $request->fullUrl();
        Log::channel("bill-query")->info("billDetailQuery日志" . date("Y-m-d H:i:s", time()), $data);
        //发起支付代码
        $service = new SPILiteService();
        $result = $service->billDetailQuerySPI($data);
        Log::channel("bill-query")->info("billDetailQueryRESULT日志" . date("Y-m-d H:i:s", time()), $result);
        return json_encode($result);
    }


    //spi.alipay.commerce.billstatistics.query
    public function billStaticQuery(Request $request)
    {
        $data = $request->all();
        $url = $request->fullUrl();
        Log::channel("bill-query")->info("billStaticQuery日志" . date("Y-m-d H:i:s", time()), $data);
        //发起支付代码
        $service = new SPILiteService();
        $result = $service->billStaticQuerySPI($data);
        Log::channel("bill-query")->info("billStaticQuery日志RESULT" . date("Y-m-d H:i:s", time()), $result);
        return json_encode($result);
    }

}